<!DOCTYPE html>
<meta charset="UTF-8">
<br>
<div style="padding: 10px; width: 80%; height: 80%">
	<table id="gridtree_action_id" data-type="gridtree" title="树形列表事件" style="width: 500px; height: 250px; padding: 10px;"
		data-defs="
				iconCls: 'icon-ok',
				rownumbers: true,
				animate: true,border:true,
				collapsible: true,
				fit:true,
				fitColumns: true,
				method:'get',url: 'demo/testdata/gridtree_data2.json',
				idField: 'id',
				treeField: 'name'
			">
		<thead>
			<tr>
				<th data-defs="field:'name',width:180">任务名称</th>
				<th data-defs="field:'persons',width:60,align:'right'">责任人</th>
				<th data-defs="field:'begin',width:80">开始日期</th>
				<th data-defs="field:'end',width:80">结束日期</th>
				<th data-defs="field:'progress',width:120,formatter:formatProgress">进程</th>
			</tr>
		</thead>
	</table>
</div>
<div style="padding: 10px;">
	<a href="javascript:void(0)" data-type="button" data-defs="'width':120" onclick="collapseAll()">关闭所有</a>
	<a href="javascript:void(0)" data-type="button" data-defs="'width':120" onclick="expandAll()">展开所有</a>
	<a href="javascript:void(0)" data-type="button" data-defs="'width':120" onclick="expandTo()">展开并选择</a>
</div>
<script type="text/javascript">
	function formatProgress(value) {
	    if (value) {
		    var s = '<div style="width:100%;border:1px solid #ccc">' + '<div style="width:' + value
		            + '%;background:#cc0000;color:#fff">' + value + '%' + '</div>'
		    '</div>';
		    return s;
	    } else {
		    return '';
	    }
    }
    function collapseAll() {
	    $('#gridtree_action_id').gridtree('collapseAll');
    }
    function expandAll() {
	    $('#gridtree_action_id').gridtree('expandAll');
    }
    function expandTo() {
	    $('#gridtree_action_id').gridtree('expandTo', 21).gridtree('select', 21);
    }
</script>
